﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sigavat.Entities;

namespace Sigavat.Repository.Mapping
{
    public class PromotorMap:EntityTypeConfiguration<Promotor>
    {
        public PromotorMap()
        {
            this.HasKey(p => p.Id);

            this.Property(p => p.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(p => p.CodigoPromotor)
                .HasMaxLength(8);

            this.Property(p => p.NumPromotor)
                .HasMaxLength(8);

            this.Property(p => p.CodEquifax);

            this.Property(p => p.Dni)
                .HasMaxLength(8);

            this.Property(p => p.Nombres)
                .HasMaxLength(200);

            this.Property(p => p.ApPaterno)
                .HasMaxLength(150);

            this.Property(p => p.ApMaterno)
                .HasMaxLength(150);

            this.Property(p => p.FechaNac);

            this.Property(p => p.Genero)
                .HasMaxLength(1);

            this.Property(p => p.Telefono)
                .HasMaxLength(10);

            this.Property(p => p.Email)
                .HasMaxLength(150);

            this.Property(p => p.Direccion)
                .HasMaxLength(200);

            this.ToTable("Promotor");
            
            this.Property(p => p.Id).HasColumnName("Id");
            this.Property(p => p.CodigoPromotor).HasColumnName("CodigoProveedor");
            this.Property(p => p.NumPromotor).HasColumnName("NumPromotor");
            this.Property(p => p.CodEquifax).HasColumnName("CodEquifax");
            this.Property(p => p.Dni).HasColumnName("Dni");
            this.Property(p => p.Nombres).HasColumnName("Nombre");
            this.Property(p => p.ApPaterno).HasColumnName("ApPaterno");
            this.Property(p => p.ApMaterno).HasColumnName("ApMaterno");
            this.Property(p => p.FechaNac).HasColumnName("FecNac");
            this.Property(p => p.Genero).HasColumnName("Genero");
            this.Property(p => p.Telefono).HasColumnName("Telefono");
            this.Property(p => p.Email).HasColumnName("Email");
            this.Property(p => p.Direccion).HasColumnName("Direccion");

            this.HasRequired(p => p.CentroComercial)
                .WithMany()
                .HasForeignKey(p => p.IdCentroComercial);




        }
    }
}
